#include "list.h"
#include "file.h"

#define   SIZE  sizeof(struct LNode)

//遍历链表
void travel(LNode* pList){
    LNode* put = pList;
    printf("\n\n\t猫猫基本信息\n");
    if(NULL == put) return;
    put = put->pNext;
    while(put){
        printf("猫猫编号: %s\n",put->data.ID);
        printf("猫猫姓名：%s\n",put->data.name);
        printf("猫猫性别：%c\n",put->data.sex);
        printf("猫猫重量(kg): %lf\n",put->data.weight);
        printf("猫猫出生日期：%s\n",put->data.date);
        put = put->pNext;
        printf("\n");
    }
    saveCat(pList);
}

//创建链表节点
LNode* createNode(Cat data){
    struct LNode* p = (LNode*)malloc(SIZE);
    if(NULL == p) NULL;//异常处理
    memset(p,0,SIZE);
    p->data = data;
    p->pNext = NULL;
    return p;
}

//数据插入，尾插法
void tailList(LNode* pList,Cat data){
    LNode* ptail = pList;
    LNode* tail = createNode(data);
    if(NULL == pList) return;
    while(ptail->pNext){
        ptail = ptail->pNext;
    }
    ptail->pNext = tail;
}